﻿@namespace MudBlazor.Docs.Examples

<MudDataGrid Items="@_persons" T="Person" Loading="_loading"
             Filterable Dense="@_dense" FixedHeader ShowMenuIcon Height="350px">
    <ToolBarContent>
        <MudSwitch Class="ml-auto" @bind-Value="@_dense" Label="Dense" />
        <MudSwitch Class="ml-2 mr-auto" @bind-Value="@_loading" Label="Loading" /> 
    </ToolBarContent>
    <ColGroup>
        <col style="width: 50px; background: var(--mud-palette-tertiary);" />
        <col />
    </ColGroup>
    <Columns>
        <PropertyColumn Property="x => x.Id" Title="Id" />
        <PropertyColumn Property="x => x.Name" Title="Name" />
    </Columns>
    <PagerContent>
        <MudDataGridPager T="Person" PageSizeOptions="new[] {10, 1000}" />
    </PagerContent>
</MudDataGrid>

@code {
    private bool _dense = false;
    private bool _loading = true;
    private readonly List<Person> _persons = Enumerable.Repeat(0, 100)
                .Select((_, i) => new Person { Id = i, Name = $"Name{i}" })
                .ToList();

    public class Person
    {
        public required int Id { get; init; }

        public required string Name { get; init; }
    }
}
